import json,yaml,csv

import pandas


def read_yaml(file):
    with open(file, 'r', encoding='utf-8') as f:
        data = yaml.safe_load(f)
    return [(i['username'], i['password'], i['exp']) for i in data]

def read_csv(file):
    data = []
    # 读取 CSV 时指定编码为gbk（避免 BOM 头影响）
    with open(file, 'r', encoding='gbk') as f:
        reader = csv.DictReader(f)
        for row in reader:
            data.append((row["username"], row["password"], row['exp']))
    return data

def read_excel(file):
    data = pandas.read_excel(file)
    data1 = []
    for index, row in data.iterrows():
        data1.append((row['username'], row['password'], row['exp']))
    return data1

def read_json(file):
    with open(file, 'r', encoding='utf-8') as f:
        data = json.load(f)
    return [(i['username'], i['password'], i['exp']) for i in data]